2020-2021 Sunseeker Telemetry and Lighting System
cs_ex2_VLOSourcesMCLK.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 //******************************************************************************
54 //*****************************************************************************
55 #include "driverlib.h"
56 #include "Board.h"
57 
58 //*****************************************************************************
59 //
60 //Variable to store current clock values
61 //
62 //*****************************************************************************
63 uint32_t clockValue;
64 
65 //*****************************************************************************
66 //
67 //Variable to store status of Oscillator fault flags
68 //
69 //*****************************************************************************
70 uint16_t status;
71 
72 void main (void)
73 {
74  //Stop watchdog timer
75  WDT_A_hold(WDT_A_BASE);
76 
77  //MCLK set out to pin
78  GPIO_setAsPeripheralModuleFunctionOutputPin(
79  GPIO_PORT_MCLK,
80  GPIO_PIN_MCLK,
81  GPIO_FUNCTION_MCLK
82  );
83 
84  /*
85  * Disable the GPIO power-on default high-impedance mode to activate
86  * previously configured port settings
87  */
88  PMM_unlockLPM5();
89 
90  //Set DCO FLL reference = REFO
91  CS_initClockSignal(
92  CS_FLLREF,
93  CS_REFOCLK_SELECT,
94  CS_CLOCK_DIVIDER_1
95  );
96 
97  //VLO Clock Sources MCLK
98  CS_initClockSignal(
99  CS_MCLK,
100  CS_VLOCLK_SELECT,
101  CS_CLOCK_DIVIDER_1
102  );
103 
104  //Clear all OSC fault flag
105  CS_clearAllOscFlagsWithTimeout(1000);
106 
107  // Enable global oscillator fault flag
108  SFR_enableInterrupt(SFR_OSCILLATOR_FAULT_INTERRUPT);
109 
110  // Enable global interrupt
111  __bis_SR_register(GIE);
112 
113  clockValue = CS_getMCLK();
114 
115  //Enter LPM3
116  __bis_SR_register(LPM3_bits);
117 
118  //For debugger
119  __no_operation();
120 }
121 
122 #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
123 #pragma vector=UNMI_VECTOR
124 __interrupt
125 #elif defined(__GNUC__)
126 __attribute__((interrupt(UNMI_VECTOR)))
127 #endif
128 void NMI_ISR(void)
129 {
130  do {
131  // If it still can't clear the oscillator fault flags after the timeout,
132  // trap and wait here.
133  status = CS_clearAllOscFlagsWithTimeout(1000);
134  } while(status != 0);
135 }
void NMI_ISR(void)
uint16_t status
void main(void)
uint32_t clockValue
__no_operation()